package secret

import (
	corev1 "k8s.io/api/core/v1"
	secretres "kubeimooc/model/secret/reponse"
	"kubeimooc/utils"
)

/*
*
k8s的secret转成
*/
type K8s2Req struct {
}

func (receiver *Req2K8s) SecretK8s2ResItemConvert(secret corev1.Secret) secretres.Secret {
	return secretres.Secret{
		Name:      secret.Name,
		Namespace: secret.Namespace,
		DataNum:   len(secret.Data),
		Age:       secret.CreationTimestamp.Unix(),
		Type:      secret.Type,
	}
}

func (receiver Req2K8s) SecretK8s2ResDetailConvert(secret corev1.Secret) secretres.Secret {
	return secretres.Secret{
		Name:      secret.Name,
		Namespace: secret.Namespace,
		DataNum:   len(secret.Data),
		Age:       secret.CreationTimestamp.Unix(),
		Type:      secret.Type,
		Data:      utils.ToListWithMapByte(secret.Data),
		Labels:    utils.ToList(secret.Labels),
	}
}
